package com.azt.novel.book.controller;



import com.azt.novel.book.dto.resp.BookChapterAboutRespDto;
import com.azt.novel.book.dto.resp.BookChapterRespDto;
import com.azt.novel.book.service.IBookChapterService;
import com.azt.novel.common.resp.RestResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 小说章节 前端控制器
 * </p>
 *
 * @author azt
 * @since 2023-12-02
 */
@RestController
@RequestMapping("/api/front/book")
public class BookChapterController {

    @Resource
    private IBookChapterService iBookChapterService;

    @Operation(summary = "小说最新章节查询接口")
    @GetMapping("/last_chapter/about")
    public RestResp<BookChapterAboutRespDto> getLastChapterAbout(@Parameter(description = "小说ID") Long bookId){
        return iBookChapterService.getLastChapterAbout(bookId);
    }
    /**
     * 获取下一章节ID接口
     * @param chapterId
     * @return
     */
    @Operation(summary = "获取下一章节ID接口")
    @GetMapping("/next_chapter_id/{chapterId}")
    public RestResp<Long> getNextChapterId(@PathVariable("chapterId") Long chapterId){
        return iBookChapterService.getNextChapterId(chapterId);
    }

    /**
     * 获取上一章节ID接口
     * @param chapterId
     * @return
     */
    @Operation(summary = "获取上一章节ID接口")
    @GetMapping("/pre_chapter_id/{chapterId}")
    public RestResp<Long> getPreChapterId(@PathVariable("chapterId") Long chapterId){
        return iBookChapterService.getPreChapterId(chapterId);
    }
    /**
     * 小说章节列表查询接口
     * @param bookId
     * @return
     */
    @Operation(summary = "小说章节列表查询接口")
    @GetMapping("/chapter/list")
    public RestResp<List<BookChapterRespDto>> listChapters(@Parameter(description = "小说ID")Long bookId){
        return iBookChapterService.listChapters(bookId);
    }


}
